
{% macro product_list_table(product_list, preview=False, editable=False, as_order=False, show_all=False) %}
	# if preview
		# set skip = []
	# elif editable
		# set skip = ['PURCHASER']
	# elif as_order
		# set skip = ['PURCHASER', 'Description']
		<div class="plus1">
			<strong>SALE TOTAL:</strong> &nbsp; ${{product_list.sale_total()|number_format(2)}}
		</div>
		<br />
		# if not show_all
			{# space for the contact details #}
			<br /><br />
		# endif
	# else
		# set skip = ['PURCHASER', 'ORDER']
	# endif
	<div class="wide-table">
	<table id="product-table">
		<tr>
		{%- for h in product_list.get_headers() %}
			# if h not in skip
				<th>{{h}}</th>
			# endif
		{% endfor -%}
		</tr>
		{%- for row in product_list.get_data(as_order=as_order and not show_all) %}
			<tr class="row-{{loop.cycle('odd', 'even')}}">
			# set row_index = loop.index0
			{%- for k in product_list.get_headers() %}
				# if k not in skip
					<td class="product-{{k.lower() | simple_name }}">
						# if editable and k == 'ORDER'
							# if row['PRICE']
							<span class="nowrap">
								<input type="text" id="row{{row_index}}-amount" class="row-amount" name="amount_{{row_index}}" value="{{row[k] or ''}}" />
								{# {{row['SOLD BY THE...']}} #}
							</span>
							# endif
						# elif editable and k == 'PRICE'
							{{row[k]}}
							<span id="row{{row_index}}-price" class="hidden">{{row[k].strip('$')}}</span>
						{#
							# elif as_order and k == 'ORDER'
								{{row[k]}} {{row['SOLD BY THE...']|plural}}
						#} 
						# else
							# if k == 'ORDER' and not row['ORDER']
								{# blank #}
							# else
								{{row[k]}} &nbsp;
								# if as_order and k == 'ORDER' and 'ORDER-details' in row
									<div style="color:#666">
										# for detail in row['ORDER-details']											<span style="white-space:nowrap">{{detail}}</span><br />										# endfor
									</div>
								# endif
							# endif
						# endif
					</td>
				# endif
			{% endfor %}
			</tr>  
		{%- endfor -%}
	</table>
	</div>
	<script type="text/javascript">$("td:last-child").css("border-right", "0px");</script>

{% endmacro %}

